package org.execute.tool.多个数据库链接;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.List;

@Component
public class DataApplicationRunner implements ApplicationRunner {
    @Autowired
    IArchiveService archiveService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<Archive> list = archiveService.list();
        HashMap<Integer, DataSource> dataSource = DatabaseUtil.getDataSource(list);
        GlobalData.setDataSource(dataSource);
    }
}
